package wq.gdky005.main.service;

import wq.gdky005.app.GlobleConstant;
import wq.gdky005.util.DBHelper;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;


public class DBCenter extends DBHelper {

	public DBCenter(Context context) {
		super(context, GlobleConstant.DB_NAME);
	}

	/** 测试例子  */
//	private final static String MAIN_TABLE = "CREATE TABLE IF NOT EXISTS "
//			+ GlobalConstant.MAIN_TABLE + "(" + GlobalConstant.MAIN_ID
//			+ " INTEGER PRIMARY KEY AUTOINCREMENT, "
//			+ GlobalConstant.MAIN_APP_NAME + " TEXT, "
//			+ GlobalConstant.MAIN_PACKAGE + " TEXT, "
//			+ GlobalConstant.MAIN_POSITION + " INTEGER, "
//			+ GlobalConstant.MAIN_PAGE + " INTEGER, " + GlobalConstant.MAIN_IMG
//			+ " TEXT, " + GlobalConstant.MAIN_UNVISIBLE + " TEXT, "
//			+ GlobalConstant.MAIN_DEFAULT + " TEXT, "
//			+ GlobalConstant.MAIN_CANDELETE + " TEXT)";
	/** 测试数据库  */
	private final static String MAIN_TABLE = "CREATE TABLE IF NOT EXISTS "
			+ GlobleConstant.MAIN_TABLE + "(" + GlobleConstant.MAIN_ID
			+ " INTEGER PRIMARY KEY AUTOINCREMENT, "
			+ GlobleConstant.MAIN_CITY + " TEXT, "
			+ GlobleConstant.MAIN_CODE + " TEXT)";


	@Override
	public void initDB(SQLiteDatabase paramSQLiteDatabase) {

		/** 测试的语句  */
		paramSQLiteDatabase.execSQL(MAIN_TABLE);

	}

	@Override
	public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int oldversion,
			int newversion) {
		oldversion = paramSQLiteDatabase.getVersion();
		paramSQLiteDatabase.setVersion(newversion);
		while (oldversion < newversion) {
			oldversion++;
			if (oldversion == 2) {
				// 高版本升级数据库信息
//				paramSQLiteDatabase.execSQL("ALTER TABLE "
//						+ GlobalConstant.NEWS_HISTORY_TABLE + " ADD "
//						+ GlobalConstant.NEWS_BRIEF + " TEXT");
			}
			// 其他版本走else if判断
		}
	}

}
